#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
using namespace std;

namespace xzy
{
	class string
	{
	public:
		/*string()
			:_str(new char[1] {'\0'})
			, _size(0)
			, _capacity(0)
		{}*/

		/*string(const char* str)
		{
			_size = strlen(str);
			_capacity = _size;
			_str = new char[_capacity + 1];
			strcpy(_str, str);
		}*/

		string(const char* str = "")
		{
			_size = strlen(str);
			_capacity = _size;
			_str = new char[_capacity + 1];
			strcpy(_str, str);
		}

		/*string(const string& str)
		{
			_str = new char[_capacity + 1];
			strcpy(_str, str._str);
			_size = str._size;
			_capacity = str._capacity;
		}*/

		/*void swap(string& str)
		{
			std::swap(_str, str._str);
			std::swap(_size, str._size);
			std::swap(_capacity, str._capacity);
		}

		string(const string& str)
		{
			string tmp(str._str);
			swap(tmp);
		}*/

		/*string& operator=(const string& str)
		{
			if (this != &str)
			{
				delete[] _str;

				_str = new char[str._capacity + 1];
				strcpy(_str, str._str);
				_size = str._size;
				_capacity = str._capacity;
 			}
			return *this;
		}*/

		/*string& operator=(const string& str)
		{
			if (this != &str)
			{
				string tmp(str);
				swap(tmp);
			}
			return *this;
		}*/

		/*string& operator=(string tmp)
		{
			swap(tmp);
			return *this;
		}*/

		~string()
		{
			if (_str != nullptr)
			{
				delete[] _str;
				_str = nullptr;
				_size = _capacity = 0;
			}
		}

		const char* c_str() const
		{
			return _str;
		}

	private:
		char* _str = nullptr;
		size_t _size = 0;
		size_t _capacity = 0;
	};
}

int main1()
{
	xzy::string s1;
	xzy::string s2("123");
	xzy::string s3(s2);

	s1 = s2;

	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
	cout << s3.c_str() << endl;

	return 0;
}

int main2()
{
	xzy::string s1("123456789");
	xzy::string s2(s1);

	//s1._capacity = 100;	

	return 0;
}